import Vue from 'vue'

function numToW(value) {

  if (value >= 10000) {
    return (value / 10000).toFixed(1) + 'w'
  } else {
    return value
  }
}

Vue.filter('numToW', numToW)


export function debounce(func, delay = 200) {
  let timer = null
  return function(...arg) {
    if (timer) clearTimeout(timer)
    timer = setTimeout(() => {
      this[func].apply(this, arg)
    }, delay)
  }
}

function formateTime(time) {
  let date = new Date(time)
  let y = date.getFullYear()
  let m = date.getMonth()
  let d = date.getDate()
  return `${y}年${m}月${d}日`
}
Vue.filter('formateTime', formateTime)
